<?php
    namespace app\user;

    include_once('./../autoloader.php');
    use app\repository\UserRepository;
    use app\HeadComponent;
    use app\alert\AlertComponent;
    
    $name = $_POST['name'];
    $username = $_POST['username'];
    $role = $_POST['role'];
    // 向数据表中插入数据
    $status = UserRepository::save($name, $username, $role);
    echo HeadComponent::render();
?>
<body>
    <script type="text/javascript">
        <? 
            if ($status === true) {
                echo AlertComponent::success('index.php', true);
            } else {
                echo AlertComponent::error($status);
            }
        ?>
    </script>
</body>
</html>

